//
//  EventBaseCell.m
//  Runone
//
//  Created by runone02 on 16/12/6.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "EventBaseCell.h"
#import "AppConstants.h"

@interface EventBaseCell ()
@property (weak, nonatomic) IBOutlet UILabel *departmentLabel; //所诉部门

@property (weak, nonatomic) IBOutlet UILabel *eventStateLabel;//事件状态
@property (weak, nonatomic) IBOutlet UIImageView *logoImageV; //事件图标
@property (weak, nonatomic) IBOutlet UILabel *eventTypeL;     //事件类型
@property (weak, nonatomic) IBOutlet UILabel *directionL;     //方向
@property (weak, nonatomic) IBOutlet UILabel *pileNOL;        //桩号
@property (weak, nonatomic) IBOutlet UILabel *dealDetailL;    //处置信息
@property (weak, nonatomic) IBOutlet UILabel *updateTimeL;    //更新时间
@end


@implementation EventBaseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _eventStateLabel.hidden = YES;
    _departmentLabel.hidden = YES;
    _dealDetailL.hidden     = YES;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
//    _dealDetailL.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 64;
    _dealDetailL.numberOfLines = 0;
    [self setLabelTextColor];
}

- (void) setLabelTextColor {
    _eventTypeL.textColor      = kTableViewCellTextColor;
    _directionL.textColor      = kTableViewCellTextColor;
    _pileNOL.textColor         = kTableViewCellTextColor;
    _dealDetailL.textColor     = kTableViewCellTextColor;
    _updateTimeL.textColor     = kTableViewCellTextColor;
    _eventStateLabel.textColor = kTableViewCellTextColor;
    _departmentLabel.textColor = kTableViewCellTextColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)setMarkInt:(EventListTitleType)markInt {//施工事件 状态
    _markInt = markInt;
    
}

- (void)setCeModel:(CurrentEvent *)ceModel {
    _ceModel = ceModel;
    
    if (_markInt == EventListTitleTypeConstruct) {
         _eventTypeL.text = _ceModel.RecordUserName;//上报人名称
        _eventStateLabel.hidden = NO;
        if (_ceModel.State == 1) {
            _eventStateLabel.text = @"未开始";
            _updateTimeL.text = [NSString stringWithFormat:@"计划开始时间：%@",_ceModel.OccurTime];
        }
        if (_ceModel.State == 2) {
            _eventStateLabel.text = @"进行中";
            _updateTimeL.text = [NSString stringWithFormat:@"更新时间：%@",_ceModel.UpdateTime];
        }
        _departmentLabel.hidden = NO;
        _departmentLabel.text   = _ceModel.RecordUserOrgName;
    }else {
    _eventTypeL.text = _ceModel.IncidentTypeName;//
    }
  
    // 图片
    if ([ceModel.IncidentParentType isEqualToString:@"3"]) {
        _logoImageV.image = [UIImage imageNamed:@"event_construct_main_icon"];
    }else {
        _logoImageV.image = [UIImage imageNamed:@"event_accident_icon"];
    }
    
    // 处置信息
    _directionL.text = ceModel.RoadDerectionName;
    if (_markInt == EventListTitleTypeHistory) {
        if (_ceModel.Content == nil) {
            _dealDetailL.hidden = YES;
        }else {
            _dealDetailL.hidden = NO;
            _dealDetailL.text   = _ceModel.Content;
        }

    }else {
        if ([_ceModel.DealDetail isEqualToString:@""] || _ceModel.DealDetail == nil || [_ceModel.DealDetail  isEqualToString:@"(null)"]) {
            _dealDetailL.hidden = YES;
        }else {
            
                _dealDetailL.hidden = NO;
                _dealDetailL.text   = [NSString stringWithFormat:@"%@",_ceModel.DealDetail];
        }
    }
    //广乐特殊的要求，只能写死
    if ([_ceModel.RoadUID isEqualToString:@"8dd13d88-cb02-4471-876b-1dfe39419ee6"]) {
        if (!_ceModel.BeginPileDistance ) {
            _ceModel.BeginPileDistance = @"0";
        }
        _pileNOL.text  = [NSString stringWithFormat:@"%@+%@",_ceModel.BeginPile,_ceModel.BeginPileDistance];
    } else {
        if (_ceModel.BeginPile) {
            NSString *LStr       = @"L";
            NSString *beginLKStr = [LStr stringByAppendingString:_ceModel.BeginPile];
            if (!_ceModel.BeginPileDistance ) {
                _ceModel.BeginPileDistance = @"0";
            }
            _pileNOL.text  = [NSString stringWithFormat:@"%@+%@",beginLKStr,_ceModel.BeginPileDistance];
        }else{
            if (!_ceModel.BeginPileDistance ) {
                _ceModel.BeginPileDistance = @"0";
            }
            _pileNOL.text  = [NSString stringWithFormat:@"%@+%@",_ceModel.BeginPile,_ceModel.BeginPileDistance];
        }
    }
    // 更新时间
    if (_markInt == EventListTitleTypeCurrent) {
        _updateTimeL.text = [NSString stringWithFormat:@"%@",_ceModel.UpdateTime];
    }
    if (_markInt == EventListTitleTypeHistory || _markInt == EventListTitleTypeToll) {
        _updateTimeL.text = [NSString stringWithFormat:@"%@",_ceModel.OccurTime];
    }
}

- (void)setTollData:(TollEvent *)tollData {
    _eventTypeL.text    = tollData.EventTypeName;
    _directionL.text    = tollData.TollStationName;
    _dealDetailL.hidden = NO;
    _dealDetailL.text   = [NSString stringWithFormat:@"值班站长:%@",tollData.DutyMonitor];
    _updateTimeL.text   = [NSString stringWithFormat:@"%@",tollData.OccurTime];
    //图片
    _logoImageV.image = [UIImage imageNamed:@"event_toll_station"];
    _pileNOL.hidden = YES;
}
#pragma mark -重用前
-(void)prepareForReuse {
    _eventStateLabel.hidden = YES;
    _departmentLabel.hidden = YES;
    _dealDetailL.hidden     = YES;
}


@end
